﻿using UnityEngine;
using System.Collections;

namespace GameBasic
{
    public interface ITask
    {
        public TaskStatus Status { get; set; }

        void OnStart() { }

        /// <summary>
        /// Called every frame
        /// </summary>
        void OnUpdate();

        void OnStop() { }
    }

    public static class ITaskExt
    {
        /// <summary>
        /// Can be scheduled?
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public static bool IsActive(this ITask task)
        {
            var s = task.Status;
            return !(s == TaskStatus.None || s == TaskStatus.End);
        }
    }
}